import os
import shutil

root = './data/custom'
file = open('./data/custom/train.txt', 'r')
line = file.readline()
while line:
    line = line.rstrip('\n')
    print(line)
    xx = os.path.basename(line)
    shutil.copy(line, '../custom/images/train/' + os.path.basename(line))
    txt_file = line.replace('images', 'labels')[:-4]
    shutil.copy(txt_file + '.txt', '../custom/labels/train/' + os.path.basename(line)[:-4] + '.txt')
    line = file.readline()
file.close()